<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <title>留言管理</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" type="text/css" href="__ADMIN__/layui/css/layui.css" media="all">
  <link rel="stylesheet" type="text/css" href="__ADMIN__/bootstrap/css/bootstrap.css" media="all">
  <link rel="stylesheet" type="text/css" href="__ADMIN__/global.css" media="all">
  <link rel="stylesheet" type="text/css" href="__ADMIN__/css/personal.css" media="all">
  <script type="text/javascript" src="__ADMIN__/jedate/jquery-1.7.2.js"></script>
</head>
<body>
<section class="layui-larry-box">
  <div class="larry-personal">
    <header class="larry-personal-tit">
      <span>请选择邮箱</span>
    </header><!-- /header -->
    <div class="layui-form-item">
        <label class="layui-form-label">留言内容</label>
        <div class="layui-input-block">
          <span>姓名: </span>{$guest.name} <span>邮箱: </span>{$guest.email}<br><br>
          <span>留言: </span>{$guest.message}<br><br>
          <span>留言时间: </span>{$guest.addtime|date="Y-m-d H:i:s",###}<br><br>
        </div>
      </div>
      <form class="layui-form" action="" method="post" onsubmit="return false ">
       <div class="layui-form-item">
        <label class="layui-form-label">主题</label>
        <div class="layui-input-block">
          <input type="text" id="title" name="title" required  lay-verify="required" value="留言信息" autocomplete="off" class="layui-input" style="width:500px;">
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">选择邮箱</label>
        <div class="layui-input-block">
          <select id="id" name="id" lay-verify="required">
            <volist name="guest_email" id="list">
              <option value="{$list.id}">{$list.name}: {$list.email}</option>
            </volist>
          </select><br>
          <input type="hidden" id="content" name="content" value="姓名:{$guest.name}&nbsp;&nbsp;邮箱:{$guest.email}&nbsp;&nbsp;留言:{$guest.message}&nbsp;&nbsp;留言时间:{$guest.addtime|date='Y-m-d H:i:s',###}">
          <div class="layui-form-item">
            <div class="layui-input-block">
              <button class="layui-btn" lay-submit="" id="close">确定</button>
            </div>
          </div>
          </form>
        </div>
      </div>
  </div>
</section>

<script src="__ADMIN__/layui/layui.js" charset="utf-8"></script>
<script>
layui.use('element', function(){
  var $ = layui.jquery
  ,element = layui.element(); //Tab的切换功能，切换事件监听等，需要依赖element模块
});
layui.use('form', function(){
  var form = layui.form();
  });
$("#close").click(function(){
  var id=$("#id").val();
  var content=$("#content").val();
  var title=$("#title").val();
  $.ajax({
    type: "GET",
    url: "{:U('Guest/upsend')}",
    data: {id:id,content:content,title:title},
    dataType:'json',
    beforeSend: function(XMLHttpRequest){
      layer.msg('转发中', {
        icon: 16,shade: [0.5, '#f5f5f5'],scrollbar: false,offset: '0px', time:10000000
      }); 
    },
    success: function(data){
      if(data==1){
        //执行关闭弹窗
        alert("转发邮件成功");
        //关闭弹窗
        parent.window.location.reload();
        var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
        parent.layer.close(index);
      }else{
        alert("转发邮件失败");
        //关闭弹窗
        parent.window.location.reload();
        var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
        parent.layer.close(index);
      }
    },
    error: function(){
      alert("请求错误");
      //关闭弹窗
      parent.window.location.reload();
      var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
      parent.layer.close(index);
    }
  });
});

</script>
</body>
</html>